package com.shop2cn.iapi.agentproducts.service;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.shop2cn.iapi.agentproducts.parameter.CatalogLinkedMapDto;
import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

import java.util.HashMap;
import java.util.List;

/**
*查询代理商品价格链Call
*FreeMaker Template自动生成代码
*/
public class QueryAgentPriceChainCall extends YmatouBaseCall {
	private static String opurl = "product/queryAgentPriceChain";

	public QueryAgentPriceChainCall() {
		super(EnvSetup.getSystemUrl("agentproducts_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	public HashMap<String, List<CatalogLinkedMapDto>> getResult() {
		HashMap<String, List<CatalogLinkedMapDto>> result =new HashMap<String, List<CatalogLinkedMapDto>>();
		try {
			result = (HashMap<String, List<CatalogLinkedMapDto>>) new Gson().fromJson(getJsonObject().get("data").getAsJsonObject().get("catalogPriceLinkMap").toString(), new TypeToken<HashMap<String, List<CatalogLinkedMapDto>>>() {}.getType());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}